package com.xkdx.caipiao.presistence.quert;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;

public class BeforeOrderAwardQueryModule extends AbsModule {
	public BeforeOrderAwardQueryInfo info;
	public boolean isSuccess = false;

	@Override
	public void parseData() throws Exception {
		try {
			backJson = (JSONArray) result;
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("Login")) {
					parseBeforeOrderAwardQuery(jsonObj
							.getJSONArray("DetailInfo"));
				}

			}
		} catch (Exception e) {
			// to do define a exception include all parseException
			throw e;
		}

	}

	private void parseBeforeOrderAwardQuery(JSONArray array) throws Exception {
		try {
			info = new BeforeOrderAwardQueryInfo();
			List<BeforeOrderAwardQueryItemInfo> list = new ArrayList<BeforeOrderAwardQueryItemInfo>();
			for (int i = 0; i < array.size(); i++) {
				JSONObject obj = array.getJSONObject(i);
				BeforeOrderAwardQueryItemInfo item = new BeforeOrderAwardQueryItemInfo();
				item.setCtime(obj
						.getString(BeforeOrderAwardQueryItemInfo.CTIME));
				item.setCuser(obj
						.getString(BeforeOrderAwardQueryItemInfo.CUSER));
				item.setDesc(obj.getString(BeforeOrderAwardQueryItemInfo.DESC));
				item.setEndtime(obj
						.getString(BeforeOrderAwardQueryItemInfo.ENDTIME));
				item.setEtime(obj
						.getString(BeforeOrderAwardQueryItemInfo.ETIME));
				item.setEuser(obj
						.getString(BeforeOrderAwardQueryItemInfo.EUSER));
				item.setFirstprize(obj
						.getString(BeforeOrderAwardQueryItemInfo.FIRSTPRIZE));
				item.setId(obj.getString(BeforeOrderAwardQueryItemInfo.ID));
				item.setIssueid(obj
						.getString(BeforeOrderAwardQueryItemInfo.ISSUEID));
				item.setLotteryid(obj
						.getString(BeforeOrderAwardQueryItemInfo.LOTTERYID));
				item.setOpenawardtime(obj
						.getString(BeforeOrderAwardQueryItemInfo.OPENAWARDTIME));
				item.setOpennum(obj
						.getString(BeforeOrderAwardQueryItemInfo.OPENNUM));
				item.setPool(obj.getString(BeforeOrderAwardQueryItemInfo.POOL));
				item.setReason(obj
						.getString(BeforeOrderAwardQueryItemInfo.REASON));
				item.setStarttime(obj
						.getString(BeforeOrderAwardQueryItemInfo.STARTTIME));
				item.setThreeprize(obj
						.getString(BeforeOrderAwardQueryItemInfo.THREEPRIZE));
				item.setTwoprize(obj
						.getString(BeforeOrderAwardQueryItemInfo.TWOPRIZE));
				list.add(item);
			}
			info.setList(list);
			isSuccess=true;

		} catch (Exception e) {
			isSuccess=false;
			throw e;
		}

	}

}
